#!/bin/bash
# Compile and link script for gsession-inhibit

user=`whoami`
if [ "$user" != "root" ] 
  then
    echo 'Error: This script needs to be run with root credentials,'
    echo "either via # sudo $0"
    echo 'or under su.'
    exit
fi

#Target dir we're copying scripts into..
TRG_SCRIPT_DIR='../../bin/unix'

#Change to the source script directory..
REL_DIR=`readlink -f $0`
SRC_SCRIPT_DIR=`dirname "$REL_DIR"`
cd "$SRC_SCRIPT_DIR"
CWD_DIR=`/bin/pwd`

if [ ! "$SRC_SCRIPT_DIR" = "$CWD_DIR" ]
  then
    echo "Error: could not change to directory $SRC_SCRIPT_DIR...exiting!"
    echo "$SRC_SCRIPT_DIR  != $CWD_DIR"
    exit -1
fi

gcc -Wall -g gsession-inhibit.c -o "${TRG_SCRIPT_DIR}/gsession-inhibit" `pkg-config --cflags --libs gtk+-2.0 dbus-glib-1`

chown squeezeboxserver:nogroup "${TRG_SCRIPT_DIR}/gsession-inhibit"
chmod 755 "${TRG_SCRIPT_DIR}/gsession-inhibit"


